package com.bruce.demo2.patterns.demo1.creational.demo05.builder.demo2;

/**
 * @PROJECT_NAME design_patterns
 * @DESCRIPTION 抽象建造者类
 * @AUTHOR CNBruceLee
 * @DATE 2021/7/12 21:56
 */
public abstract class Builder {
    /**
     * 声明Bike类型的变量，并进行赋值
     */
    protected Bike mBike = new Bike();

    /**
     * 组装车架
     */
    public abstract void builderFrame();

    /**
     * 组装座椅
     */
    public abstract void builderSeat();

    /**
     * 创建自行车
     * @return Bike 创建自行车
     */
    public abstract Bike createBike();

    /**
     * 组装自行车
     *
     * @return Bike
     */
    public Bike construct() {
        //具体组装过程可能有一定的顺序
        this.builderFrame();//组装车架
        this.builderSeat();//组装座椅
        return this.mBike;//返回组装后的自行车
    }


}
